<?php
include("../../inc/global.inc");
include("islogin.php");
$id = intval($_GET['id']);
$head['title']='托管交易-发货';	
$row=$db->get_one("SELECT * FROM `sd_tuoguan` WHERE id=$id and status=3 and userid2=".$per_row['id']);
if(!$row){
 echo "<script>location='/err.html';</script>";
}
if(isset($_POST['submit']) && $_POST['submit'])
{
	$array = $_POST['info'];
	
	$array['inputtime']=time();
	$array['updatetime']=time();
	$array['ip']=ip();
	$array['userid']=$per_row['id'];
	$array['userid2']=$row['userid'];
	$array['username']=$per_row['m_user'];
	$array['username2']=$row['username'];
	
	$true = $db->insert('sd_fahuo', $array);
	if($true)
	{
		$array2['status'] = 4;
		$array2['updatetime'] = time();
		$db->update('sd_tuoguan', $array2,"id=".$_POST['info']['tuoguanid']." and userid2=".$per_row['id']);
		echo "<script>alert('发货成功');location='/member/tuoguan/shoukuan.php?fukuan=2';</script>";exit;
	}
	else
	{
		echo "<script>alert('发货失败，未知原因。请联系管理员');location='".HTTP_REFERER."';</script>";exit;
	}
}
include("top.php");
?>
<div class="con">
		   <div class="top5"><span>您当前位置：<a href="/help/">会员助手</a> &gt;&gt; <?php echo $head['title'];?></span></div>
		   <?php include("left.php");?>
		   <div class="right">
		      <div class="y_5"></div>
		       <div class="con-tt"><span>发货提示</span></div>
			   <div class="con-t1" style="height:auto;"><span>买家已汇款，请您务必在15天内发货并及时填写提交发货信息，如有需要延期的请您及时联系买家协商延期时间（5天、10天、15天，系统默认为10天） 并提交申请延期，买家确认后，延期生效，或者到期交易自动结束，产品款退还给买家。</span></div>
			   <div class="con-t2"><form action="" method="post" onsubmit="return check();">
               		<input type="hidden" name="info[tuoguanid]" value="<?php echo $id;?>" />
					<table width="100%" border="0" cellpadding="0" cellspacing="0" >
					 <tr>
		                <td height="30" bgcolor="#EFF6FF" align="center">发货时间：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[ftime]"  id="ftime" type="text" class="txt5" value="<?php echo date('Y-m-d H:i:s');?>"/></td>
	                </tr>
					 <tr>
		                <td height="30" bgcolor="#EFF6FF" align="center">物流公司名称：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[wlgs]"  id="wlgs" type="text" class="txt1"/>
	                     <span>*</span></td>
	                </tr>
					 <tr>
		                <td height="30" bgcolor="#EFF6FF" align="center">物流运单号：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[wldh]"  id="wldh" type="text" class="txt1"/>
	                     <span>*</span></td>
	                </tr>
					<tr>
		                <td height="30" bgcolor="#EFF6FF" align="center">物流联系电话：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[wltel]"  id="wltel" type="text" class="txt1"/> </td>
	                </tr>
                    <tr>
		                <td height="30" bgcolor="#EFF6FF" align="center">预计几天到货：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[tian]"  id="tian" type="text"  class="txt2"/>
	                    天</td>
	                </tr>
                    <tr>
		                <td height="30" bgcolor="#EFF6FF" align="center">备注：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><textarea name="info[content]" class="txt3" cols="70" rows="15"></textarea></td>
	                </tr>
					  <tr>
		                <td height="35" bgcolor="#EFF6FF">&nbsp;</td>
		                <td colspan="2" bgcolor="#f9f9f9">&nbsp;<input name="submit" type="submit" id="submit" value="提交" class="btn1"/></td>
	                </tr>
                    <tr>
		                <td height="35"  align="center" bgcolor="#EFF6FF">&nbsp;</td>
		                <td colspan="2" bgcolor="#f9f9f9"><div class="txt red">请注意：a. 卖家请您一定要诚信经营，确保您发的产品是和买家商谈好一致的，或者您也许会货、款两空。<br />
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 	b. 你在本次正常交易中必须在15天内填写发货信息，或者本次托管交易自动结束，
托管方将本次<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;托管的产品款退还给付款方。
</div></td>
	                </tr>
                 </table></form>
               </div>
		 </div>
		 <div class="cl"></div>
</div> 
<?php include("foot.php");?>
<script>
	function check()
	{
		if($('#ftime').val()=='')
		{
			alert('请输入发货时间');
			$('#ftime').focus();
			return false;
		}
		if($('#wlgs').val()=='')
		{
			alert('请输入物流公司');
			$('#wlgs').focus();
			return false;
		}
		if($('#wldh').val()=='')
		{
			alert('请输入物流单号');
			$('#wldh').focus();
			return false;
		}
		if($('#wltel').val()=='')
		{
			alert('请输入物流电话');
			$('#wltel').focus();
			return false;
		}
	}
</script>
